Add new parser option "PreSaveTransform" that allows the pre-save transformation to be selectively disabled.
* (bug 6672) Images are now autorotated according to their EXIF orientation.
This only affects thumbnails; the source remains unrotated.
* (bug 25708) Update case mappings and normalization to Unicode 6.0.0
+* New hook ArticlePrepareTextForEdit added, called when preparing text to be saved.
+* New parser option PreSaveTransform added, allows the pre-save transformation
+ to be selectively disabled.
=== Bug fixes in 1.18 ===
* (bug 23119) WikiError class and subclasses are now marked as deprecated
$article: article (object) that data will be loaded
$fields: fileds (array) to load from the database
+'ArticlePrepareTextForEdit': called when preparing text to be saved
+$article: the article being saved
+$popts: parser options to be used for pre-save transformation
+
'ArticleProtect': before an article is protected
$article: the article being protected
$user: the user doing the protection
global $wgParser;
+ if( $user === null ) {
+ global $wgUser;
+ $user = $wgUser;
+ }
+ $popts = ParserOptions::newFromUser( $user );
+ wfRunHooks( 'ArticlePrepareTextForEdit', array( $this, $popts ) );
+
$edit = (object)array();
$edit->revid = $revid;
$edit->newText = $text;
- $edit->pst = $this->preSaveTransform( $text, $user );
+ $edit->pst = $this->preSaveTransform( $text, $user, $popts );
$edit->popts = $this->getParserOptions( true );
$edit->output = $wgParser->parse( $edit->pst, $this->mTitle, $edit->popts, true, true, $revid );
$edit->oldText = $this->getRawText();
* @param $text String article contents
* @param $user User object: user doing the edit, $wgUser will be used if
* null is given
+ * @param $popts ParserOptions object: parser options, default options for
+ * the user loaded if null given
* @return string article contents with altered wikitext markup (signatures
* converted, {{subst:}}, templates, etc.)
*/
- public function preSaveTransform( $text, User $user = null ) {
+ public function preSaveTransform( $text, User $user = null, ParserOptions $popts = null ) {
global $wgParser;
if ( $user === null ) {
$user = $wgUser;
}
- return $wgParser->preSaveTransform( $text, $this->mTitle, $user, ParserOptions::newFromUser( $user ) );
+ if ( $popts === null ) {
+ $popts = ParserOptions::newFromUser( $user );
+ }
+
+ return $wgParser->preSaveTransform( $text, $this->mTitle, $user, $popts );
}
/* Caching functions */
"\r\n" => "\n",
);
$text = str_replace( array_keys( $pairs ), array_values( $pairs ), $text );
- $text = $this->pstPass2( $text, $user );
+ if( $options->getPreSaveTransform() ) {
+ $text = $this->pstPass2( $text, $user );
+ }
$text = $this->mStripState->unstripBoth( $text );
$this->setUser( null ); #Reset
var $mTimestamp; # Timestamp used for {{CURRENTDAY}} etc.
var $mExternalLinkTarget; # Target attribute for external links
var $mCleanSignatures; #
+ var $mPreSaveTransform = true; # Transform wiki markup when saving the page.
var $mNumberHeadings; # Automatically number headings
var $mMath; # User math preference (as integer)
function getIsPrintable() { $this->optionUsed('printable');
return $this->mIsPrintable; }
function getUser() { return $this->mUser; }
+ function getPreSaveTransform() { return $this->mPreSaveTransform; }
function getSkin( $title = null ) {
if ( !isset( $this->mSkin ) ) {
function setMath( $x ) { return wfSetVar( $this->mMath, $x ); }
function setUserLang( $x ) { return wfSetVar( $this->mUserLang, $x ); }
function setThumbSize( $x ) { return wfSetVar( $this->mThumbSize, $x ); }
+ function setPreSaveTransform( $x ) { return wfSetVar( $this->mPreSaveTransform, $x ); }
function setIsPreview( $x ) { return wfSetVar( $this->mIsPreview, $x ); }
function setIsSectionPreview( $x ) { return wfSetVar( $this->mIsSectionPreview, $x ); }